package org.dftproject.gedcom.core.persistence;

import org.dftproject.gedcom.core.IGedcom;
import org.dftproject.genesis.core.persistence.IMemento;
import org.dftproject.genesis.core.persistence.IPersistenceFactory;
import org.dftproject.genesis.core.persistence.PersistenceUtils;

public class GedcomPersonFactory implements IPersistenceFactory {
	
	public static final String ID = GedcomPersonFactory.class.getName();

	public Object createObject(IMemento memento) {
		IPersistenceFactory factory = PersistenceUtils.getFactory(memento.getString("gedcomFactoryId"));
		Object gedcom = factory.createObject(memento.getChild("gedcom"));
		if (gedcom instanceof IGedcom)
			return ((IGedcom) gedcom).getPerson(memento.getString("xref"));
		return null;
	}

}
